home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / insight / plugins / myppm.pro < prev    next >
Text File  |  1997-07-08  |  4KB  |  107 lines

  1. ; $Id: myppm.pro,v 1.2 1997/03/21 22:17:49 rob Exp $
  2. ;
  3. ; Copyright (c) 1997, Research Systems, Inc.  All rights reserved.
  4. ;   Unauthorized reproduction prohibited.
  5. ;+
  6. ; FILE:
  7. ;       myppm.pro
  8. ;
  9. ; PURPOSE:
  10. ;       This file contains an example File PlugIn that handles PPM/PGM files.
  11. ;
  12. ; CONTENTS:
  13. ;       CALLBACK ROUTINES
  14. ;           pro ReadMyPPM       - reads a file
  15. ;           pro WriteMyPPM      - writes a file
  16. ;
  17. ;       REGISTRATION FUNCTION
  18. ;           fun MyPPM           - registers the PlugIn
  19. ;
  20. ;-
  21.  
  22. ; *****************************************************************************
  23. ;       CALLBACK ROUTINES
  24. ; *****************************************************************************
  25.  
  26. ; -----------------------------------------------------------------------------
  27. ;   
  28. ;    Purpose:  File PlugIn Read Routine.
  29. ;
  30. pro ReadMyPPM, $
  31.     filename, $         ; IN: name of file to read
  32.     name, $             ; IN: suggested data name based on file name
  33.     TAIL=tail, $        ; IN: (opt) filename w/out directory, e.g., myfile.ppm
  34.     GROUP=wGroup, $     ; IN: (opt) ID of widget group leader
  35.     _EXTRA=extra        ; IN: information to pass to INSPUT
  36.  
  37.     ;  Read the file.
  38.     ;
  39.     READ_PPM, filename, image
  40.  
  41.     ;  Set the data description.
  42.     ;
  43.     description = 'Read from "' + tail + '" PPM/PGM file.'
  44.  
  45.     ;  Put the data into the Data Manager.
  46.     ;
  47.     INSPUT, $
  48.         image,      $                               ; the data to put
  49.         /IMAGE,     $                               ; input is an image
  50.         NAME        = name, $                       ; the name to give it
  51.         DESCRIPTION = description, $                ; the data description
  52.         GROUP       = wGroup, $                     ; widget group leader
  53.         _EXTRA      = extra                         ; extra information
  54.         
  55. end             ; ReadMyPPM
  56.  
  57. ; -----------------------------------------------------------------------------
  58. ;   
  59. ;    Purpose:  File PlugIn Write Routine.
  60. ;
  61. pro WriteMyPPM, $
  62.     filename, $         ; IN: name of file to write to
  63.     name, $             ; IN: name of data item to write, e.g., mydata
  64.     TAIL=tail, $        ; IN: (opt) filename w/out directory, e.g., myfile.ppm
  65.     GROUP=wGroup, $     ; IN: (opt) ID of widget group leader
  66.     _EXTRA=extra        ; IN: information to pass to INSPUT
  67.  
  68.     ;  Get the data from the Data Manager.
  69.     ;
  70.     image = INSGET( $
  71.         name,       $                               ; data item to write
  72.         GROUP       = wGroup, $                     ; widget group leader
  73.         _EXTRA      = extra)                        ; extra information
  74.  
  75.     ;  Write the data to the file.
  76.     ;
  77.     WRITE_PPM, filename, image
  78.  
  79. end             ; WriteMyPPM
  80.  
  81. ; *****************************************************************************
  82. ;       REGISTRATION FUNCTION
  83. ; *****************************************************************************
  84.  
  85. ; -----------------------------------------------------------------------------
  86. ;   
  87. ;    Purpose:  Register the file PlugIn.
  88. ;
  89. function MyPPM
  90.  
  91.     ;  Return the File PlugIn Registration Structure.
  92.     ;
  93.     RETURN, { $
  94.         type:       'File_PlugIn', $                ; PlugIn type
  95.         title:      'My PPM/PGM Format', $          ; PlugIn title
  96.         purpose:    'Handle PPM/PGM files.', $      ; PlugIn purpose
  97.         read_proc:  'ReadMyPPM', $                  ; read callback
  98.         write_proc: 'WriteMyPPM', $                 ; write callback
  99.         file_ext:   ['ppm','pgm'], $                ; extension(s) (no period)
  100.         version:    '5.0', $                        ; IDL version
  101.         revision:   '1.0' $                         ; PlugIn version
  102.         }
  103.  
  104. end             ; MyPPM
  105.  
  106. ; -----------------------------------------------------------------------------
  107.